home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue51 / Construc / Server51_TLB.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-09-24  |  12.8 KB  |  329 lines

  1. unit Server51_TLB;
  2.  
  3. // ************************************************************************ //
  4. // WARNING                                                                    
  5. // -------                                                                    
  6. // The types declared in this file were generated from data read from a       
  7. // Type Library. If this type library is explicitly or indirectly (via        
  8. // another type library referring to this type library) re-imported, or the   
  9. // 'Refresh' command of the Type Library Editor activated while editing the   
  10. // Type Library, the contents of this file will be regenerated and all        
  11. // manual modifications will be lost.                                         
  12. // ************************************************************************ //
  13.  
  14. // PASTLWTR : $Revision:   1.88  $
  15. // File generated on 1999/09/24 14:52:58 from Type Library described below.
  16.  
  17. // *************************************************************************//
  18. // NOTE:                                                                      
  19. // Items guarded by $IFDEF_LIVE_SERVER_AT_DESIGN_TIME are used by properties  
  20. // which return objects that may need to be explicitly created via a function 
  21. // call prior to any access via the property. These items have been disabled  
  22. // in order to prevent accidental use from within the object inspector. You   
  23. // may enable them by defining LIVE_SERVER_AT_DESIGN_TIME or by selectively   
  24. // removing them from the $IFDEF blocks. However, such items must still be    
  25. // programmatically created via a method of the appropriate CoClass before    
  26. // they can be used.                                                          
  27. // ************************************************************************ //
  28. // Type Lib: D:\usr\bob\magazine\DELPHI.MAG\#51\src\Server51.tlb (1)
  29. // IID\LCID: {A2A63DA2-7257-11D3-BE12-00104BF89DAD}\0
  30. // Helpfile: 
  31. // DepndLst: 
  32. //   (1) v2.0 stdole, (C:\WINNT\System32\STDOLE2.TLB)
  33. //   (2) v4.0 StdVCL, (C:\WINNT\System32\STDVCL40.DLL)
  34. //   (3) v1.0 Midas, (C:\WINNT\System32\midas.dll)
  35. // ************************************************************************ //
  36. {$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers. 
  37. interface
  38.  
  39. uses Windows, ActiveX, Classes, Graphics, OleServer, OleCtrls, StdVCL, 
  40.   MIDAS;
  41.  
  42. // *********************************************************************//
  43. // GUIDS declared in the TypeLibrary. Following prefixes are used:        
  44. //   Type Libraries     : LIBID_xxxx                                      
  45. //   CoClasses          : CLASS_xxxx                                      
  46. //   DISPInterfaces     : DIID_xxxx                                       
  47. //   Non-DISP interfaces: IID_xxxx                                        
  48. // *********************************************************************//
  49. const
  50.   // TypeLibrary Major and minor versions
  51.   Server51MajorVersion = 1;
  52.   Server51MinorVersion = 0;
  53.  
  54.   LIBID_Server51: TGUID = '{A2A63DA2-7257-11D3-BE12-00104BF89DAD}';
  55.  
  56.   IID_ITDM: TGUID = '{A2A63DA3-7257-11D3-BE12-00104BF89DAD}';
  57.   CLASS_TDM: TGUID = '{A2A63DA5-7257-11D3-BE12-00104BF89DAD}';
  58. type
  59.  
  60. // *********************************************************************//
  61. // Forward declaration of types defined in TypeLibrary                    
  62. // *********************************************************************//
  63.   ITDM = interface;
  64.   ITDMDisp = dispinterface;
  65.  
  66. // *********************************************************************//
  67. // Declaration of CoClasses defined in Type Library                       
  68. // (NOTE: Here we map each CoClass to its Default Interface)              
  69. // *********************************************************************//
  70.   TDM = ITDM;
  71.  
  72.  
  73. // *********************************************************************//
  74. // Interface: ITDM
  75. // Flags:     (4416) Dual OleAutomation Dispatchable
  76. // GUID:      {A2A63DA3-7257-11D3-BE12-00104BF89DAD}
  77. // *********************************************************************//
  78.   ITDM = interface(IAppServer)
  79.     ['{A2A63DA3-7257-11D3-BE12-00104BF89DAD}']
  80.   end;
  81.  
  82. // *********************************************************************//
  83. // DispIntf:  ITDMDisp
  84. // Flags:     (4416) Dual OleAutomation Dispatchable
  85. // GUID:      {A2A63DA3-7257-11D3-BE12-00104BF89DAD}
  86. // *********************************************************************//
  87.   ITDMDisp = dispinterface
  88.     ['{A2A63DA3-7257-11D3-BE12-00104BF89DAD}']
  89.     function  AS_ApplyUpdates(const ProviderName: WideString; Delta: OleVariant; 
  90.                               MaxErrors: Integer; out ErrorCount: Integer; var OwnerData: OleVariant): OleVariant; dispid 20000000;
  91.     function  AS_GetRecords(const ProviderName: WideString; Count: Integer; out RecsOut: Integer; 
  92.                             Options: Integer; const CommandText: WideString; 
  93.                             var Params: OleVariant; var OwnerData: OleVariant): OleVariant; dispid 20000001;
  94.     function  AS_DataRequest(const ProviderName: WideString; Data: OleVariant): OleVariant; dispid 20000002;
  95.     function  AS_GetProviderNames: OleVariant; dispid 20000003;
  96.     function  AS_GetParams(const ProviderName: WideString; var OwnerData: OleVariant): OleVariant; dispid 20000004;
  97.     function  AS_RowRequest(const ProviderName: WideString; Row: OleVariant; RequestType: Integer; 
  98.                             var OwnerData: OleVariant): OleVariant; dispid 20000005;
  99.     procedure AS_Execute(const ProviderName: WideString; const CommandText: WideString; 
  100.                          var Params: OleVariant; var OwnerData: OleVariant); dispid 20000006;
  101.   end;
  102.  
  103. // *********************************************************************//
  104. // The Class CoTDM provides a Create and CreateRemote method to          
  105. // create instances of the default interface ITDM exposed by              
  106. // the CoClass TDM. The functions are intended to be used by             
  107. // clients wishing to automate the CoClass objects exposed by the         
  108. // server of this typelibrary.                                            
  109. // *********************************************************************//
  110.   CoTDM = class
  111.     class function Create: ITDM;
  112.     class function CreateRemote(const MachineName: string): ITDM;
  113.   end;
  114.  
  115.  
  116. // *********************************************************************//
  117. // OLE Server Proxy class declaration
  118. // Server Object    : TTDM
  119. // Help String      : TDM Object
  120. // Default Interface: ITDM
  121. // Def. Intf. DISP? : No
  122. // Event   Interface: 
  123. // TypeFlags        : (2) CanCreate
  124. // *********************************************************************//
  125. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  126.   TTDMProperties= class;
  127. {$ENDIF}
  128.   TTDM = class(TOleServer)
  129.   private
  130.     FIntf:        ITDM;
  131. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  132.     FProps:       TTDMProperties;
  133.     function      GetServerProperties: TTDMProperties;
  134. {$ENDIF}
  135.     function      GetDefaultInterface: ITDM;
  136.   protected
  137.     procedure InitServerData; override;
  138.   public
  139.     constructor Create(AOwner: TComponent); override;
  140.     destructor  Destroy; override;
  141.     procedure Connect; override;
  142.     procedure ConnectTo(svrIntf: ITDM);
  143.     procedure Disconnect; override;
  144.     function  AS_ApplyUpdates(const ProviderName: WideString; Delta: OleVariant; 
  145.                               MaxErrors: Integer; out ErrorCount: Integer; var OwnerData: OleVariant): OleVariant;
  146.     function  AS_GetRecords(const ProviderName: WideString; Count: Integer; out RecsOut: Integer; 
  147.                             Options: Integer; const CommandText: WideString; 
  148.                             var Params: OleVariant; var OwnerData: OleVariant): OleVariant;
  149.     function  AS_DataRequest(const ProviderName: WideString; Data: OleVariant): OleVariant;
  150.     function  AS_GetProviderNames: OleVariant;
  151.     function  AS_GetParams(const ProviderName: WideString; var OwnerData: OleVariant): OleVariant;
  152.     function  AS_RowRequest(const ProviderName: WideString; Row: OleVariant; RequestType: Integer; 
  153.                             var OwnerData: OleVariant): OleVariant;
  154.     procedure AS_Execute(const ProviderName: WideString; const CommandText: WideString; 
  155.                          var Params: OleVariant; var OwnerData: OleVariant);
  156.     property  DefaultInterface: ITDM read GetDefaultInterface;
  157.   published
  158. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  159.     property Server: TTDMProperties read GetServerProperties;
  160. {$ENDIF}
  161.   end;
  162.  
  163. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  164. // *********************************************************************//
  165. // OLE Server Properties Proxy Class
  166. // Server Object    : TTDM
  167. // (This object is used by the IDE's Property Inspector to allow editing
  168. //  of the properties of this server)
  169. // *********************************************************************//
  170.  TTDMProperties = class(TPersistent)
  171.   private
  172.     FServer:    TTDM;
  173.     function    GetDefaultInterface: ITDM;
  174.     constructor Create(AServer: TTDM);
  175.   protected
  176.   public
  177.     property DefaultInterface: ITDM read GetDefaultInterface;
  178.   published
  179.   end;
  180. {$ENDIF}
  181.  
  182.  
  183. procedure Register;
  184.  
  185. implementation
  186.  
  187. uses ComObj;
  188.  
  189. class function CoTDM.Create: ITDM;
  190. begin
  191.   Result := CreateComObject(CLASS_TDM) as ITDM;
  192. end;
  193.  
  194. class function CoTDM.CreateRemote(const MachineName: string): ITDM;
  195. begin
  196.   Result := CreateRemoteComObject(MachineName, CLASS_TDM) as ITDM;
  197. end;
  198.  
  199. procedure TTDM.InitServerData;
  200. const
  201.   CServerData: TServerData = (
  202.     ClassID:   '{A2A63DA5-7257-11D3-BE12-00104BF89DAD}';
  203.     IntfIID:   '{A2A63DA3-7257-11D3-BE12-00104BF89DAD}';
  204.     EventIID:  '';
  205.     LicenseKey: nil;
  206.     Version: 500);
  207. begin
  208.   ServerData := @CServerData;
  209. end;
  210.  
  211. procedure TTDM.Connect;
  212. var
  213.   punk: IUnknown;
  214. begin
  215.   if FIntf = nil then
  216.   begin
  217.     punk := GetServer;
  218.     Fintf:= punk as ITDM;
  219.   end;
  220. end;
  221.  
  222. procedure TTDM.ConnectTo(svrIntf: ITDM);
  223. begin
  224.   Disconnect;
  225.   FIntf := svrIntf;
  226. end;
  227.  
  228. procedure TTDM.DisConnect;
  229. begin
  230.   if Fintf <> nil then
  231.   begin
  232.     FIntf := nil;
  233.   end;
  234. end;
  235.  
  236. function TTDM.GetDefaultInterface: ITDM;
  237. begin
  238.   if FIntf = nil then
  239.     Connect;
  240.   Assert(FIntf <> nil, 'DefaultInterface is NULL. Component is not connected to Server. You must call ''Connect'' or ''ConnectTo'' before this operation');
  241.   Result := FIntf;
  242. end;
  243.  
  244. constructor TTDM.Create(AOwner: TComponent);
  245. begin
  246.   inherited Create(AOwner);
  247. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  248.   FProps := TTDMProperties.Create(Self);
  249. {$ENDIF}
  250. end;
  251.  
  252. destructor TTDM.Destroy;
  253. begin
  254. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  255.   FProps.Free;
  256. {$ENDIF}
  257.   inherited Destroy;
  258. end;
  259.  
  260. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  261. function TTDM.GetServerProperties: TTDMProperties;
  262. begin
  263.   Result := FProps;
  264. end;
  265. {$ENDIF}
  266.  
  267. function  TTDM.AS_ApplyUpdates(const ProviderName: WideString; Delta: OleVariant; 
  268.                                MaxErrors: Integer; out ErrorCount: Integer; 
  269.                                var OwnerData: OleVariant): OleVariant;
  270. begin
  271.   Result := DefaultInterface.AS_ApplyUpdates(ProviderName, Delta, MaxErrors, ErrorCount, OwnerData);
  272. end;
  273.  
  274. function  TTDM.AS_GetRecords(const ProviderName: WideString; Count: Integer; out RecsOut: Integer; 
  275.                              Options: Integer; const CommandText: WideString; 
  276.                              var Params: OleVariant; var OwnerData: OleVariant): OleVariant;
  277. begin
  278.   Result := DefaultInterface.AS_GetRecords(ProviderName, Count, RecsOut, Options, CommandText, 
  279.                                            Params, OwnerData);
  280. end;
  281.  
  282. function  TTDM.AS_DataRequest(const ProviderName: WideString; Data: OleVariant): OleVariant;
  283. begin
  284.   Result := DefaultInterface.AS_DataRequest(ProviderName, Data);
  285. end;
  286.  
  287. function  TTDM.AS_GetProviderNames: OleVariant;
  288. begin
  289.   Result := DefaultInterface.AS_GetProviderNames;
  290. end;
  291.  
  292. function  TTDM.AS_GetParams(const ProviderName: WideString; var OwnerData: OleVariant): OleVariant;
  293. begin
  294.   Result := DefaultInterface.AS_GetParams(ProviderName, OwnerData);
  295. end;
  296.  
  297. function  TTDM.AS_RowRequest(const ProviderName: WideString; Row: OleVariant; RequestType: Integer; 
  298.                              var OwnerData: OleVariant): OleVariant;
  299. begin
  300.   Result := DefaultInterface.AS_RowRequest(ProviderName, Row, RequestType, OwnerData);
  301. end;
  302.  
  303. procedure TTDM.AS_Execute(const ProviderName: WideString; const CommandText: WideString; 
  304.                           var Params: OleVariant; var OwnerData: OleVariant);
  305. begin
  306.   DefaultInterface.AS_Execute(ProviderName, CommandText, Params, OwnerData);
  307. end;
  308.  
  309. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  310. constructor TTDMProperties.Create(AServer: TTDM);
  311. begin
  312.   inherited Create;
  313.   FServer := AServer;
  314. end;
  315.  
  316. function TTDMProperties.GetDefaultInterface: ITDM;
  317. begin
  318.   Result := FServer.DefaultInterface;
  319. end;
  320.  
  321. {$ENDIF}
  322.  
  323. procedure Register;
  324. begin
  325.   RegisterComponents('Servers',[TTDM]);
  326. end;
  327.  
  328. end.
  329.